View Javadoc
1 2 package jrre; 3 4 import jrre.gui.JavaStackFrameGui; 5 import jrre.gui.OperandFrameGui; 6 7 import jrre.instructionset.Instruction; 8 import jrre.classloader.classfile.attributes.LocalVariableAttributeTable; 9 10 import jrre.types.*; 11 /*** 12 * 13 * 14 * @author Christopher Ellsworth (Chris@chrisellsworth.com) 15 * @author Clerance Alston (massclax@hotmail.com) 16 */ 17 public class StackFrame { 18 19 /* 20 private static JavaStackFrameGui stackFrameGui = new JavaStackFrameGui(); 21 private static StackFrame stackPointer; 22 */ 23 private StackFrame nextFrame; 24 private StackFrame previousFrame; 25 26 private jrre.api.java.lang.Class classContainingMethod; 27 28 private OperandStack operandStack; 29 private LocalVariableFrame localVariableFrame; 30 private Instruction instructions; 31 32 private int localVariableSize; 33 private int maxStackSize; 34 35 /*** 36 * Constructor. 37 */ 38 public StackFrame(){ 39 40 operandStack = new OperandStack(); 41 localVariableFrame = new LocalVariableFrame(); 42 } 43 44 /*** 45 * Gets the MaxStackSize. 46 */ 47 public int getMaxStackSize(){ 48 return this.maxStackSize; 49 } 50 51 /*** 52 * Sets the MaxStackSize. 53 * @param MaxStackSize The value to set it to. 54 */ 55 public void setMaxStackSize(int maxStackSize){ 56 this.maxStackSize = maxStackSize; 57 } 58 59 public void clear(){ 60 61 operandStack.clear(); 62 } 63 64 /*** 65 * Gets the ClassContainingMethod. 66 */ 67 public jrre.api.java.lang.Class getClassContainingMethod(){ 68 return this.classContainingMethod; 69 } 70 71 72 /*** 73 * Sets the ClassContainingMethod. 74 * @param ClassContainingMethod The value to set it to. 75 */ 76 public void setClassContainingMethod(jrre.api.java.lang.Class classContainingMethod){ 77 this.classContainingMethod = classContainingMethod; 78 } 79 80 81 82 /*** 83 * Gets the OperandStack. 84 */ 85 public OperandStack getOperandStack(){ 86 return this.operandStack; 87 } 88 89 /*** 90 * Sets the OperandStack. 91 * @param OperandStack The value to set it to. 92 */ 93 public void setOperandStack(OperandStack operandStack){ 94 this.operandStack = operandStack; 95 } 96 97 /*** 98 * Gets the PreviousFrame. 99 */ 100 public StackFrame getPreviousFrame(){ 101 return this.previousFrame; 102 } 103 104 /*** 105 * Sets the PreviousFrame. 106 * @param PreviousFrame The value to set it to. 107 */ 108 public void setPreviousFrame(StackFrame previousFrame){ 109 this.previousFrame = previousFrame; 110 } 111 112 public StackFrame getNextFrame(){ 113 return nextFrame; 114 } 115 116 public void setNextFrame(StackFrame newFrame){ 117 this.nextFrame = newFrame; 118 } 119 120 public Type getLocalVariable(int variableIndex){ 121 return localVariableFrame.getLocalVariable(variableIndex); 122 } 123 124 public void setLocalVariable(int variableIndex, Type value){ 125 126 localVariableFrame.setLocalVariable(variableIndex, value); 127 } 128 129 public Instruction getCurrentInstruction(){ 130 131 return this.instructions; 132 } 133 134 /*** 135 * Gets the Instructions. 136 */ 137 public Instruction getInstructions(){ 138 return this.instructions; 139 } 140 141 /*** 142 * Sets the Instructions. 143 * @param Instructions The value to set it to. 144 */ 145 public void setInstructions(Instruction instructions){ 146 this.instructions = instructions; 147 } 148 149 /*** 150 * Gets the LocalVariableSize. 151 */ 152 public int getLocalVariableSize() { 153 return this.localVariableSize; 154 } 155 156 /*** 157 * Sets the LocalVariableSize. 158 * @param LocalVariableSize The value to set it to. 159 */ 160 public void setLocalVariableSize(int localVariableSize){ 161 this.localVariableSize = localVariableSize; 162 163 localVariableFrame.setSize(localVariableSize); 164 } 165 166 public Instruction getNextInstruction(){ 167 168 Instruction toReturn = instructions; 169 170 if(instructions != null) 171 instructions = instructions.getNextInstruction(); 172 173 return toReturn; 174 } 175 176 public Instruction getPrevInstruction(){ 177 178 if(instructions != null) 179 instructions = instructions.getPrevInstruction(); 180 181 return instructions; 182 } 183 184 public void restoreLastInstruction(){ 185 186 instructions = instructions.getPrevInstruction(); 187 } 188 189 public String toString(){ 190 191 StringBuffer toReturn = new StringBuffer(); 192 Instruction instructionCorsur = instructions; 193 194 toReturn.append("\n\tInstructions: "); 195 while(instructionCorsur != null){ 196 //toReturn.append("\n\t\t"+instructionCorsur); 197 toReturn.append("\n\t\t"+instructionCorsur.toString()); 198 instructionCorsur = instructionCorsur.getNextInstruction(); 199 } 200 201 return toReturn.toString(); 202 } 203 }

This page was automatically generated by Maven